﻿using DotNetLib.Windows.Forms;

using ExtensibleEventViewer.Core.Primitives;


namespace ExtensibleEventViewer.Console.Adapters
{
	internal class EventLogRecordAdapter : AdapterBase<EventLogRecord>
	{
		internal EventLogRecordAdapter(EventLogRecord eventLogRecord):base(eventLogRecord)
		{
		}

		protected override ContainerListViewItem CreateListViewItem(EventLogRecord eventLogRecord)
		{
			ContainerListViewItem item = new ContainerListViewItem();

			ContainerListViewSubItem sourceNameSubItem = new ContainerListViewSubItem(0);
			sourceNameSubItem.Text = eventLogRecord.Source;

			ContainerListViewSubItem dateSubItem = new ContainerListViewSubItem(1);
			dateSubItem.Text = eventLogRecord.TimeGenerated.ToString();

			ContainerListViewSubItem levelSubItem = new ContainerListViewSubItem(3);
			levelSubItem.Text = eventLogRecord.Type.ToString();

			ContainerListViewSubItem userSubItem = new ContainerListViewSubItem(2);
			userSubItem.Text = eventLogRecord.UserName;

			item.SubItems.Add(sourceNameSubItem);
			item.SubItems.Add(dateSubItem);
			item.SubItems.Add(userSubItem);
			item.SubItems.Add(levelSubItem);

			return item;	
		}
	}
}
